package vlcjdemo;

import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.ArrayList;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;

public class Hmi extends javax.swing.JFrame implements ImageList.RenderValues {

    JFrame aJFrame;
    ImageList aImageList;
    ImageList aOutImageList;
    volatile ArrayList<MovieClip> aMovieList = new ArrayList<MovieClip>();
    volatile ArrayList<MovieClip> aOutMovieList = new ArrayList<MovieClip>();
    volatile String movieFile = "C:\\aa\\mov\\saved\\Anita_Blonde_-_orient_express.avi";
    FFprobeParser inFFprobeParser = new FFprobeParser();
    FFprobeParser outFFprobeParser = new FFprobeParser();
    String filename = File.separator + "jtn";
    JFileChooser fc = new JFileChooser(new File(filename));
    //OpenFileFilter openFileFilter = new OpenFileFilter();
    volatile String TITLE = "Mp4MovieCreator";
    volatile int clipcount = 0;
    String STOPJOB = "No running task";

    /** Creates new form ${name} */
    public Hmi(JFrame lJFrame) {
        aJFrame = lJFrame;
        aJFrame.setTitle(TITLE);
        jobStop();
        MovieClip[] items = aOutMovieList.toArray(new MovieClip[0]);
        aOutImageList = new ImageList((int) FFprobeParser.thumbNailWidth + 6, (int) 150 + 24, Hmi.this, items);
        JComponent aImageListView = aOutImageList.getView();

//        javax.swing.GroupLayout outPanelLayout = new javax.swing.GroupLayout(outPanel);
//        outPanel.setLayout(outPanelLayout);
//        outPanelLayout.setHorizontalGroup(
//                outPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(outPanelLayout.createSequentialGroup().addContainerGap().addComponent(aImageListView, javax.swing.GroupLayout.DEFAULT_SIZE, (int) inFFprobeParser.thumbNailWidth + 6 + 20, Short.MAX_VALUE).addContainerGap()));
//        outPanelLayout.setVerticalGroup(
//                outPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(outPanelLayout.createSequentialGroup().addContainerGap().addComponent(aImageListView, javax.swing.GroupLayout.DEFAULT_SIZE, 850, Short.MAX_VALUE).addContainerGap()));
//        outPanel.repaint();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        createMovieButton = new javax.swing.JButton();
        importMovieButton = new javax.swing.JButton();
        widthTextField = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        heightTextField = new javax.swing.JTextField();
        sizeCheckBox = new javax.swing.JCheckBox();
        jobsLabel = new javax.swing.JLabel();
        profileCheckBox = new javax.swing.JCheckBox();
        outPanel = new javax.swing.JPanel();
        insertOutButton = new javax.swing.JButton();
        removeOutButton = new javax.swing.JButton();
        clearOutButton = new javax.swing.JButton();
        playButton = new javax.swing.JButton();
        playMovieButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 281, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 546, Short.MAX_VALUE)
        );

        createMovieButton.setText("Create Movie");
        createMovieButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                createMovieButtonActionPerformed(evt);
            }
        });

        importMovieButton.setText("Import Movie");
        importMovieButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                importMovieButtonActionPerformed(evt);
            }
        });

        widthTextField.setText("480");

        jLabel1.setText("x");

        heightTextField.setText("320");

        sizeCheckBox.setSelected(true);
        sizeCheckBox.setText("size");

        jobsLabel.setBackground(new java.awt.Color(153, 153, 255));
        jobsLabel.setForeground(new java.awt.Color(0, 0, 255));
        jobsLabel.setText("No running jobs");

        profileCheckBox.setSelected(true);
        profileCheckBox.setText("old compatibility mode");

        javax.swing.GroupLayout outPanelLayout = new javax.swing.GroupLayout(outPanel);
        outPanel.setLayout(outPanelLayout);
        outPanelLayout.setHorizontalGroup(
            outPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 210, Short.MAX_VALUE)
        );
        outPanelLayout.setVerticalGroup(
            outPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 546, Short.MAX_VALUE)
        );

        insertOutButton.setText(">>");
        insertOutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                insertOutButtonActionPerformed(evt);
            }
        });

        removeOutButton.setText("Remove");
        removeOutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                removeOutButtonActionPerformed(evt);
            }
        });

        clearOutButton.setText("Clear");
        clearOutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                clearOutButtonActionPerformed(evt);
            }
        });

        playButton.setText("Play");
        playButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                playButtonActionPerformed(evt);
            }
        });

        playMovieButton.setText("Play Movie");
        playMovieButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                playMovieButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(11, 11, 11)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(14, 14, 14)
                                .addComponent(sizeCheckBox)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(widthTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 7, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(heightTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addGap(39, 39, 39)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jobsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(importMovieButton, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                        .addComponent(removeOutButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(clearOutButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(playButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(insertOutButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(playMovieButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(createMovieButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addGap(24, 24, 24))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(profileCheckBox)
                        .addGap(18, 18, 18)))
                .addComponent(outPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(outPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGap(20, 20, 20)
                        .addComponent(jobsLabel)
                        .addGap(18, 18, 18)
                        .addComponent(importMovieButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(insertOutButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(removeOutButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(clearOutButton)
                        .addGap(5, 5, 5)
                        .addComponent(playButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(widthTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1)
                            .addComponent(heightTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(sizeCheckBox))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(profileCheckBox)
                        .addGap(18, 18, 18)
                        .addComponent(createMovieButton)
                        .addGap(18, 18, 18)
                        .addComponent(playMovieButton)))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void createMovieButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createMovieButtonActionPerformed

        Runnable createMovie = new Runnable() {

            public void run() {
                String lmovieFile = movieFile;
//                FFprobeParser lFFprobeParser = aFFprobeParser;
                try {
//                    Object[] selected = aImageList.getSelectedObjects();
//                    aOutMovieList.clear();
//                    for (Object object : selected) {
//                        aOutMovieList.add((MovieClip) object);
//                    }
                    outFFprobeParser = new FFprobeParser();
                    outFFprobeParser.aMovieOutList = aOutMovieList;
                    int lwidth = Integer.parseInt(widthTextField.getText());
                    int lheight = Integer.parseInt(heightTextField.getText());

                    outFFprobeParser.baselineProfile = profileCheckBox.isSelected();
                    jobStart("Generating clips");
                    outFFprobeParser.writeFFMpegCmd(sizeCheckBox.isSelected(), lwidth, lheight);
                    jobStart("Appending clips");
                    outFFprobeParser.writeAppendCmd(lmovieFile + clipcount + ".mp4");
                    clipcount++;
                    jobStop();
                } catch (Exception x) {
                    x.printStackTrace();
                }
            }
        };

        new Thread(createMovie).start();
    }//GEN-LAST:event_createMovieButtonActionPerformed

    private void importMovieButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_importMovieButtonActionPerformed
        if (openFile()) {
            jPanel1.removeAll();
            jPanel1.repaint();

            Runnable importMovie = new Runnable() {

                public void run() {
                    try {
                        jobStart("Parsing Movie");
                        final FFprobeParser aFFprobeParser = new FFprobeParser();
                        inFFprobeParser = aFFprobeParser;
                        aFFprobeParser.writeFFProbeCmd(movieFile);
                        jobStart("Creating thumbnails");
                        aFFprobeParser.writeJpgCmd();
                        aMovieList = aFFprobeParser.aMovieList;
                        jobStart("Loading thumbnails");

                        Runnable endImportMovie = new Runnable() {

                            public void run() {

                                MovieClip[] items = aMovieList.toArray(new MovieClip[0]);
                                aImageList = new ImageList((int) aFFprobeParser.thumbNailWidth + 6, (int) aFFprobeParser.thumbNailHeight + 24, Hmi.this, items);
                                JComponent aImageListView = aImageList.getView();

//        javax.swing.JScrollPane jScrollPane1 = new javax.swing.JScrollPane();
                                javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
                                jPanel1.setLayout(jPanel1Layout);
                                jPanel1Layout.setHorizontalGroup(
                                        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(aImageListView, javax.swing.GroupLayout.DEFAULT_SIZE, (int) aFFprobeParser.thumbNailWidth + 6 + 20, Short.MAX_VALUE).addContainerGap()));
                                jPanel1Layout.setVerticalGroup(
                                        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(aImageListView, javax.swing.GroupLayout.DEFAULT_SIZE, 850, Short.MAX_VALUE).addContainerGap()));
                                jPanel1.repaint();
                                jobStop();
                                clipcount = 0;
                            }
                        };
                        SwingUtilities.invokeLater(endImportMovie);
                    } catch (Exception x) {
                        x.printStackTrace();
                    }
                }
            };

            new Thread(importMovie).start();
        }
    }//GEN-LAST:event_importMovieButtonActionPerformed

    private void insertOutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_insertOutButtonActionPerformed
        Object[] selected = aImageList.getSelectedObjects();
        Object[] outSelected = aOutImageList.getSelectedObjects();
        int idx = -1;
        if (outSelected.length > 0) {
            idx = aOutMovieList.indexOf(outSelected[outSelected.length - 1]);
        }

        ArrayList<MovieClip> aTempList = new ArrayList<MovieClip>();
        for (Object obj : selected) {
            aTempList.add((MovieClip) obj);
        }

        if (idx > -1) {
            aOutMovieList.addAll(idx, aTempList);
        } else {
            aOutMovieList.addAll(aTempList);
        }
        MovieClip[] items = aOutMovieList.toArray(new MovieClip[0]);
        aOutImageList.setItems(items);
    }//GEN-LAST:event_insertOutButtonActionPerformed

    private void removeOutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeOutButtonActionPerformed
        Object[] selected = aOutImageList.getSelectedObjects();
//                    aOutMovieList.clear();
        for (Object object : selected) {
            aOutMovieList.remove((MovieClip) object);
        }
        MovieClip[] items = aOutMovieList.toArray(new MovieClip[0]);
        aOutImageList.setItems(items);
    }//GEN-LAST:event_removeOutButtonActionPerformed

    private void clearOutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_clearOutButtonActionPerformed
        aOutMovieList.clear();
        MovieClip[] items = aOutMovieList.toArray(new MovieClip[0]);
        aOutImageList.setItems(items);
    }//GEN-LAST:event_clearOutButtonActionPerformed

    private void playButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_playButtonActionPerformed
        Runnable playMovie = new Runnable() {

            public void run() {
                try {
                    Object[] selected = aImageList.getSelectedObjects();
                    if (selected.length > 0) {
                        MovieClip aMovieClip = (MovieClip) selected[selected.length - 1];
                        inFFprobeParser.writePlayCmd(aMovieClip);
                    }
                } catch (Exception x) {
                    x.printStackTrace();
                }
            }
        };

        new Thread(playMovie).start();
    }//GEN-LAST:event_playButtonActionPerformed

    private void playMovieButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_playMovieButtonActionPerformed
        Runnable playMovie = new Runnable() {

            public void run() {
                try {
                    if (outFFprobeParser != null) {
                        outFFprobeParser.writePlayMovieCmd();
                    }
                } catch (Exception x) {
                    x.printStackTrace();
                }
            }
        };

        new Thread(playMovie).start();

    }//GEN-LAST:event_playMovieButtonActionPerformed

    boolean openFile() {
        boolean ret = false;
        // Show dialog; this method does not return until dialog is closed
        fc.setMultiSelectionEnabled(false);
//	fc.setFileFilter(openFileFilter);
        fc.setDialogTitle("Open movie file .....");
//	if (aSciencePaperPanel.getCurrentFile() != null) {
//	  File f = new File(aSciencePaperPanel.getCurrentFile());
//	  fc.setSelectedFile(f);
//	}
        int result = fc.showOpenDialog(this);

        // Determine which button was clicked to close the dialog
        switch (result) {
            case JFileChooser.APPROVE_OPTION:
                // Approve (Open or Save) was clicked
                // Get the selected file
                File f = fc.getSelectedFile();
                movieFile = f.getPath();
                setTitle(TITLE + ": " + f.getPath());
                ret = true;
                break;
            case JFileChooser.CANCEL_OPTION:
                break;
            case JFileChooser.ERROR_OPTION:
                // The selection process did not complete successfully
                break;
        }
        return ret;
    }

    void jobStart(String message) {
        jobState(true, message);
    }

    void jobStop() {
        jobState(false, STOPJOB);
    }

    void jobState(final boolean running, final String message) {
        Runnable runjob = new Runnable() {

            public void run() {
                if (running) {
                    createMovieButton.setEnabled(false);
                    jobsLabel.setBackground(new java.awt.Color(255, 153, 153));
                    jobsLabel.setForeground(new java.awt.Color(255, 0, 0));
                    jobsLabel.setText(message);
                } else {
                    createMovieButton.setEnabled(true);
                    jobsLabel.setBackground(new java.awt.Color(153, 153, 255));
                    jobsLabel.setForeground(new java.awt.Color(0, 0, 255));
                    jobsLabel.setText(message);
                }
            }
        };
        SwingUtilities.invokeLater(runjob);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Hmi().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton clearOutButton;
    private javax.swing.JButton createMovieButton;
    private javax.swing.JTextField heightTextField;
    private javax.swing.JButton importMovieButton;
    private javax.swing.JButton insertOutButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel jobsLabel;
    private javax.swing.JPanel outPanel;
    private javax.swing.JButton playButton;
    private javax.swing.JButton playMovieButton;
    private javax.swing.JCheckBox profileCheckBox;
    private javax.swing.JButton removeOutButton;
    private javax.swing.JCheckBox sizeCheckBox;
    private javax.swing.JTextField widthTextField;
    // End of variables declaration//GEN-END:variables

    @Override
    public void requestCellImage(ImageList list, Object obj, int imageWidth, int imageHeight) {
        MovieClip aMovieClip = (MovieClip) obj;
        String theUrl = aMovieClip.jpgName;
        ImageIcon anotherIcon = new ImageIcon(theUrl);

//MediaTracker media = new MediaTracker(this);
//        Image image =
//                Toolkit.getDefaultToolkit().getImage(theUrl);
//        media.addImage(image, 0);
        try {
//            media.waitForID(0);
            int type = BufferedImage.TYPE_INT_RGB;
            BufferedImage bimage = new BufferedImage(imageWidth, imageHeight, type);
            Graphics g = bimage.createGraphics();
            Image aImage = anotherIcon.getImage();
            g.drawImage(aImage, 0, 0, null);
            g.dispose();

            list.putImage(obj, bimage);
            aImage.flush();
        } catch (Exception e) {
            e.printStackTrace();
        }


    }

    @Override
    public String getCellText(ImageList list, Object obj) {
        MovieClip aMovieClip = (MovieClip) obj;
        return "T:" + aMovieClip.time + ", D:" + aMovieClip.duration;
    }

    @Override
    public String getTooltipText(ImageList list, FontMetrics tooltipMetrics, Object obj) {
        MovieClip aMovieClip = (MovieClip) obj;
        return "Movie: " + aMovieClip.parrent.movieName;
    }
}
